<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fnt" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE HTML>
<html>
<head>
    <title>忘记密码</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="keywords" content="Instant Sign In Form Widget Responsive, Login Form Web Template, Flat Pricing Tables, Flat Drop-Downs, Sign-Up Web Templates, Flat Web Templates, Login Sign-up Responsive Web Template, Smartphone Compatible Web Template, Free Web Designs for Nokia, Samsung, LG, Sony Ericsson, Motorola Web Design">
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <link href="<%=path%>/web/css/popup-box.css" rel="stylesheet" type="text/css" media="all" />
    <link href="<%=path%>/web/css/style.css" rel='stylesheet' type='text/css' />
    <link href="<%=path%>/web/css/font-awesome.css" rel="stylesheet">
    <link href="//fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet">
    <link href="//fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&amp;subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese" rel="stylesheet">
    <!--js-->
    <script type="text/javascript" src="<%=path%>/web/js/jquery-2.1.4.min.js"></script>
    <!--//js-->
</head>
<body>
<div class="agileinfo-dot">
    <h1>忘记密码</h1>
    <div class="login-section">
        <div class="login-w3l">
            <h2 class="sub-head-w3-agileits">更改密码</h2>
            <div class="login-form">

                <form id="ForgetPasswordForm" action="<%=path%>/services/isForgetCode" method="post">
                    <div class="input">
                        <input type="text" class="user" name="email" id="email" placeholder="请输入邮箱账号" required="" />
                        <span id="emailMsg"></span>
                    </div>
                    <div class="input">
        <input type="text" name="emailCode" id="emailCode" class="emailCode" placeholder="请输入验证码" required=""/>
             <span id="emailCodeMsg"></span>
                        <a href="javascript:void(0)" id="sendCode">
                            <div style="width: 32%;font-size: 14px;color:#f5f5f5;float: left;line-height: 40px;padding-left: 7px" id="text">获取验证码</div>
                        </a>
         </div >
                    <div class="input">
    <input type="submit" id="subBtn" value="前往验证">
    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("#email").blur(TEmail) ;
    });
    function TEmail() {
        var path = "<%=path%>";
        var email = $("#email").val();
        var flag1;
        $.get(path+"/services/isEmail",
            {email:email},
            function (data){
                if(data==1)
                {
                    $("#emailMsg").html("√");
                    $("#emailMsg").css("color", "green");
                    flag1 = true;
                }
                if(data==0)
                {
                    $("#emailMsg").html("该邮箱尚未注册或格式错误");
                    $("#emailMsg").css("color", "red");
                    flag1 = false;
                }
            }
        );
        return flag1;
    }
    $(function() {
        $("#sendCode").click(sendCode);
    });
    function sendCode() {
        var path = "<%=path%>";
        var email = $("#email").val();
        var reg = /^\w+(\.\w+)*@\w+\.\w{2,4}(\.\w+)?$/;
        if (email == "") {
            $("#emailMsg").html("请输入邮箱");
            $("#emailMsg").css("color", "red");
        } else {
            alert(email);
            $.get(path+"/services/sendUpdateEmail",
                {email:email},
                function (data) {
                    if(data=="0"){
                        $("#text").html("重新获取验证码");
                        $("#email").attr("readonly", "readonly");
                        $("#email").css("cursor", "not-allowed");
                        $("#email").css("background-color", "#FBFBFB");
                    }
                }
            );
        }
    }

</script>


</body>
</html>

